package rwt.server.handlers.web;

import rwt.server.*;
import rwt.server.WebMessages.GetSwitches;
import rwt.server.WebMessages.PutSwitches;
import rwt.server.core.*;

public class GetSwitchesHandler  extends MessageHandler<GetSwitches>
{

	@Override
	public void handle(GetSwitches message, IConnection source) throws Exception 
	{
		if (!(source instanceof IClient))
			throw new IllegalArgumentException("GetSwitches did not come from a client.");
		
		IClient client = (IClient) source;
		PutSwitches msg = new PutSwitches(RailServer.getSwitchManager().getSwitchMap());
		client.write(msg);
	}

}
